//
//  FMDatabaseHelper.m
//  DataBaseTest
//
//  Created by 赵小燕 on 16/12/15.
//  Copyright © 2016年 xiaoyanzhao. All rights reserved.
//

#import "FMDatabaseHelper.h"


static char dbPath[200];
static FMDatabaseHelper *instance = nil;
@implementation FMDatabaseHelper

+ (FMDatabaseHelper *)sharedInstance {
    static dispatch_once_t onceToken = 0;
//    static FMDatabaseHelper *instance = nil;
    dispatch_once(&onceToken, ^{
        instance = [[FMDatabaseHelper alloc] init];
    });
    return instance;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        _queueDB = [FMDatabaseQueue databaseQueueWithPath:[self getPath]];
    }
    return self;
}

- (NSString *)getPath {
    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *directory = [path objectAtIndex:0];
    strcpy(dbPath, [[directory stringByAppendingPathComponent:@"dataFMDB.sqlite"] UTF8String]);
    NSLog(@"111111 %@", directory);
    return [NSString stringWithUTF8String:dbPath];
}

@end
